﻿' ----------------------------------------------------------------------
'
' NodeAttributes.vb
'
'   ... Classes
'
'   This class contains the implementation of a single folder.
'
' ----------------------------------------------------------------------
' version:  1.0.0.1
' today:    02/09/06  11:26:00
' ident:    "@(#)/dbfs/NodeAttributes.vb 1.0 0.1 02/09/09 0 rjs"

Imports Dbfs.Data


Namespace Dbfs

    Public Class NodeAttributes
        Inherits Dictionary(Of String, String)

        ' class variables
        Private _isDirty As Boolean
        Private _nodeId As Integer


#Region " Constructors "
        Public Sub New()
            _isDirty = False
            _nodeId = 0
        End Sub

        Public Sub New(ByVal nodeId As Integer)
            _isDirty = False
            _nodeId = nodeId
        End Sub
#End Region

#Region " Properties "
        ''' <summary>
        ''' Gets a flag indicating if this collection has been modified.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property IsDirty() As Boolean
            Get
                Return _isDirty
            End Get
        End Property

        Public Property NodeId() As Integer
            Get
                Return _nodeId
            End Get
            Set(ByVal value As Integer)
                _nodeId = value
            End Set
        End Property
#End Region ' Properties

#Region " Methods "
        Public Overloads Sub Add(ByVal key As String, ByVal value As String)
            MyBase.Add(key, value)
            _isDirty = True
        End Sub

        ''' <summary>
        ''' Removes the value with the specified key from the Dictionary.
        ''' </summary>
        ''' <param name="key">The key of the element to remove.</param>
        ''' <returns><b>true</b> if the element is successfully found and removed; otherwise, 
        ''' <b>false</b>. This method returns <b>false</b> if key is not found in the Dictionary.</returns>
        ''' <remarks></remarks>
        Public Overloads Function Remove(ByVal key As String) As Boolean
            MyBase.Remove(key)
            _isDirty = True
        End Function

        Public Function Copy() As NodeAttributes
            Dim col As New NodeAttributes
            For Each member In Me
                col.Add(member.Key, member.Value)
            Next
            Return col
        End Function

        Public Sub Copy(ByVal attributeCollection As NodeAttributes)
            For Each key As String In attributeCollection.Keys
                Add(key, attributeCollection(key))
            Next
        End Sub
#End Region ' Methods

    End Class

End Namespace
